<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<script>
    window.parent_json=null;
</script>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <% String path = request.getContextPath();%>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="<%=path%>/layui/css/layui.css">
    <script src="<%=path%>/layui/layui.js" type="text/javascript"></script>
    <script src="<%=path%>/jquery-3.4.1.js" type="text/javascript"></script>
</head>
<body onload="init();">
<div class="layui-container" >
    <div class="layui-row">
        <form class="layui-form" style="margin-top: 5%;">
            <div class="layui-form-item layui-form-text"  style="font-size: 15px; margin-left: 9%;">
                <label class="layui-label" ><i class="layui-icon"style="font-size: 18px; color: red;">&#xe702;</i> 您确定要取消申请吗？取消申请后，再次申请时需要重新审批！确认取消则需要点击下方“确认取消”。</label>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">您已申请</label>
                <div class="layui-input-block">
                    <input type="text" name="labName" disabled="disabled" placeholder="实验室名称" class="layui-input" id="input_labName">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">申请时段</label>
                <div class="layui-input-block">
                    <input type="text" name="labWeek" disabled="disabled" placeholder="预约时间+预约时段" class="layui-input" id="input_time">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">申请人数</label>
                <div class="layui-input-block">
                    <input type="text" name="labType" disabled="disabled" placeholder="申请人数" class="layui-input" id="input_applyCount">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">申请理由</label>
                <div class="layui-input-block">
                    <textarea name="labRes" disabled="disabled" placeholder="申请理由" class="layui-textarea" style="resize: none;" id="input_reason"></textarea>
                </div>
            </div>
            <div class="layui-form-item" style="margin-top: 6%;  margin-left: 13%;">
                <div class="layui-input-block">
                    <button id="btn" class="layui-btn layui-btn-normal" onclick="again();return false;">确认取消</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="<%=path%>/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    function init() {
        parent_json = eval('('+parent.json+')');
        $('#input_labName').val(parent_json.lib);
        $('#input_time').val(parent_json.time);
        $('#input_applyCount').val(parent_json.num);
        $('#input_reason').val(parent_json.apply_reason);
    }
    window.onload=init;
    function again() {
        var index = parent.layer.getFrameIndex(window.name);
        $.ajax({
            type:"POST"
            ,dataType:"json"
            ,url:"${pageContext.request.contextPath}/jsp/apply.do?method=cancelApply&applyID="+parent_json.applyID
            ,success:function (data) {
                if (data.ok === "yes"){
                    layer.msg("已取消申请😏",{time:2000},function () {
                        parent.render();
                        parent.layer.close(index);
                    });
                }else {
                    layer.msg("取消失败，请稍后重试！😫",{time:2000},function () {
                        parent.layer.close(index);
                    });
                }
            }
            ,error:function () {
                layer.msg("取消失败，请稍后重试！😫",{time:2000},function () {
                    parent.layer.close(index);
                });
            }
        });
    }
</script>

</body>
</html>